//
//  CouponsTableViewCell.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/25.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "CouponsTableViewCell.h"

@implementation CouponsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpUI];
    }
    return self;
}
- (void)setUpUI
{
    self.backgroundColor = tableViewBgColor;
    UIImageView *bottomImg = [[UIImageView alloc] init];
    bottomImg.image = UIImageNamed(@"bottomWhiteImg");
    [bottomImg sizeToFit];
    [self addSubview:bottomImg];
    [bottomImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.centerX.equalTo(self);
    }];
    
    self.bgImg = [[UIImageView alloc] init];
    _bgImg.image = UIImageNamed(@"couponWeishiyong"); // couponYishiyong couponShixiao
    [_bgImg sizeToFit];
    [self addSubview:_bgImg];
    [_bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(bottomImg.mas_top);
        make.centerX.equalTo(self);
    }];
    
    UILabel *label1 = [UILabel labelWithText:@"￥" textColor:UIColorWhite fontSize:24];
    [label1 sizeToFit];
    [_bgImg addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgImg).offset(rateWidth(40));
        make.top.equalTo(self.bgImg).offset(rateHeight(30));
    }];
    
    UILabel *label2 = [UILabel labelWithText:@"优惠券" textColor:UIColorWhite fontSize:20];
    [label2 sizeToFit];
    [_bgImg addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.bgImg);
        make.top.equalTo(self.bgImg).offset(rateHeight(40));
    }];
    
    self.moneyLB = [UILabel labelWithText:@"10" textColor:UIColorWhite fontSize:60];
    [self.moneyLB sizeToFit];
    [_bgImg addSubview:self.moneyLB];
    [self.moneyLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(label1.mas_right).offset(rateWidth(10));
        make.centerY.equalTo(self.bgImg).offset(rateHeight(10));
    }];
    
    self.conditionLB = [UILabel labelWithText:@"满199元使用" textColor:UIColorWhite fontSize:15];
    [self.conditionLB sizeToFit];
    [_bgImg addSubview:self.conditionLB];
    [self.conditionLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(label2);
        make.top.equalTo(label1.mas_bottom).offset(rateHeight(25));
    }];
    
    self.describeLB = [UILabel labelWithText:@"全部商品可用，不可抵扣运费" textColor:UIColorFromRGB(0x999999) fontSize:12];
    [self.describeLB sizeToFit];
    [bottomImg addSubview:self.describeLB];
    [self.describeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(bottomImg);
        make.left.equalTo(bottomImg.mas_left).offset(rateWidth(70));
    }];
    
    self.timeLB = [UILabel labelWithText:@"2018.07.12-2018.07.31" textColor:UIColorFromRGB(0x999999) fontSize:12];
    [self.timeLB sizeToFit];
    [bottomImg addSubview:self.timeLB];
    [self.timeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(bottomImg);
        make.right.equalTo(bottomImg.mas_right).offset(-rateWidth(70));
    }];
}

@end
